# $Id: inspircd.tcl 18 2012-01-06 23:56:32Z nickoos85@gmail.com $

set ::altera(protocol) "inspircd"


proc altera:lancement { } {
	set ::inlink 1
	set ::altera(uptime) [clock seconds]
	altera:sendRaw "SERVER $::altera(link) $::altera(pass) 0 $::altera(sid) :$::altera(info)"
	altera:sendRaw ":$::altera(sid) BURST [clock seconds]"
	altera:botcreate
	altera:sendRaw ":$::altera(sid) ENDBURST"
}

proc altera:botcreate { } {
	altera:sendRaw ":$::altera(sid) UID $::altera(uid) [clock seconds] $::altera(pseudo) $::altera(host) $::altera(host) $::altera(ident) $::altera(host) [clock seconds] +Siosw +ABCKNOQcdfgklnoqtx :$::altera(realname)"
	altera:sendRaw ":$::altera(uid) JOIN $::altera(salon)"
	altera:sendRaw ":$::altera(sid) MODE $::altera(salon) +ao $::altera(pseudo) $::altera(pseudo)"
}

proc event {s} {
    gets $s data
    if { [eof $s] } {
	 close $::altera(idx)
        puts "EOF"
        exit
    }
    set arg [split $data]

    #Debug
    if {$::altera(debug) == 1} { puts "<== $arg" }
    altera:event $arg
}
